<template>
	<view class="content">
		<z-paging ref="paging" v-model="tableData" @query="searchReport" :auto="false" loading-more-no-more-text="没有更多了"
			use-virtual-list :topZIndex="999" :bottomZIndex="10" :auto-show-back-to-top="backTopType"
			:back-to-top-style="{ 'opacity':0.6 }">

			<!-- z-paging默认铺满全屏，此时页面所有view都应放在z-paging标签内，否则会被盖住 -->
			<!-- 需要固定在页面顶部的view请通过slot="top"插入，包括自定义的导航栏 -->
			<template #top>
				<u-navbar :fixed="false" :title="titleName" :autoBack="true" :safeAreaInsetTop="true"
					leftIconColor="#fff">
					<view slot="right">
						<m-bubble type="list" :selectData="formMenus" position="right" topOpsotion="right"
							bgcRgba="#fff" color="#333" @selectFun="TapPopup">
							<u-icon name="more-dot-fill" color="#fff" class="moremenu"></u-icon>
						</m-bubble>
					</view>
				</u-navbar>
				<!-- <view class="search">
					<u-search :placeholder="searchPlaceHolder" v-model="keyword" :show-action="false" shape="square"
						class="searchDom"></u-search>
					<u-icon name="scan" class="scanQrCode" size="25"></u-icon>
				</view> -->

				<!-- <view class="search x-bc">
					<u-search :placeholder="searchPlaceHolder" v-model="keyword" :show-action="false" shape="square"
						@search="handleSizeChange(1,30)" class="searchDom"></u-search>
					<u-icon name="scan" class="scanQrCode" color="#fff" size="30" style="margin-right: 10px;"></u-icon>
				</view> -->


				<view class="MenuBoxMax">
					<view class="f-dc MenuBox">

						<m-dropdown ref="mDropdown" titleSize="14px" menuIconSize="14px" height="40"
							:style="{'overflow': stickShow ? 'hidden' : ''}" @open="dropDowmOpen"
							@close="stickShow = true">
							<!-- 时间选择 -->
							<!-- <m-dropdown-item v-for="row in formDesign"
								v-if="row.baseProperty.controlType == 'datepicker'" :rowInfo="row"
								:title="queryConditions[row.baseProperty.controlName + '_show'] || row.baseProperty.labelName">
								<m-date-time :InitData="DropDowmMenu_Date[row.baseProperty.controlName]"
									@DateSubmit="DateSubmit($event,row)"></m-date-time>
							</m-dropdown-item> -->


							<m-dropdown-item v-for="row in formDesign"
								v-if="row.baseProperty.controlType == 'datepicker'" :rowInfo="row"
								:title="queryConditions[row.baseProperty.controlName + '_show'] || row.baseProperty.labelName">
								<template #desc="{element}">
									<view
										style="background-color: #f2f2f2;padding: 6px 15px;color: #999;font-size: 12px;">
										{{element.baseProperty.labelName}}
									</view>
								</template>
								<m-date-time pickerType="picker"
									:InitDataPicker="DropDowmMenu_Date[row.baseProperty.controlName]"
									@DateSubmit="DateSubmit($event,row)"></m-date-time>
							</m-dropdown-item>

							<!-- 项目选择 -->
							<m-dropdown-item :title="MenuTitleBack(row)" v-model="queryConditions[row.colName]"
								:format="{label:'text',value:'value'}" v-for="row in queryColumns"
								v-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 1"
								:options="getQuerySelectColumns(row)" @change="changeValue">
								<template #desc="{element}">
									<view
										style="background-color: #f2f2f2;padding: 6px 15px;color: #999;font-size: 12px;">
										{{element.labelName}}
									</view>
								</template>
							</m-dropdown-item>


							<view slot="filter" class="selectSearchDom x-c">
								<view class="x-c" style="border-left:1px solid #cdcdcd;padding:10px;color:#818181 "
									@click="choiceParams">
									筛选<uni-icons fontFamily="CustomFontPlatform" color="#818181"
										style="position: relative; top:3rpx;"
										:size="20">{{$utils.toUniCode('&#xe811;')}}</uni-icons>
								</view>
							</view>
						</m-dropdown>

					</view>

				</view>

			</template>

			<!-- <template #cell="{item,index}"> -->
			<template v-for="(item,index) in tableData">
				<view class="content_main_CardBox" style="margin-bottom: 10rpx;">
					<view class="x-bc content_main_CardBox_TopBox">
						<text class="content_main_CardBox_TopBox_TitleName"
							v-if="columns.length>0">{{titleBackFun(item,columns)}}</text>

					</view>
					<view class="x-bc" style="height: 100%;position: relative;">
						<view class="formBox" style="flex: 1;">
							<view class="FiledBox" v-for="(col) in VForFilterDataBack(columns)">
								<text class="FiledBox_label_f24 FiledBox_grifola">{{col.colDesc}}:</text>
								<text
									class="FiledBox_value FiledBox_value_f24 FiledBox_grifola">{{item[col.colName]}}</text>
							</view>

						</view>

						<view class="y-end" style="position: absolute;right: 10rpx;bottom: 10rpx;">
							<uni-icons v-if="!isSelectedItem(item)" type="plus-filled" color="#51d0d0" :size="28"
								@click="choiceItem(item)"></uni-icons>

							<uni-icons v-else type="checkmarkempty" color="#51d0d0" :size="28"></uni-icons>


						</view>


					</view>
				</view>
			</template>

			<template #bottom>
				<view class="bottomTool x-bc" :style="$utils.disposeSafeBottomFun()">
					<view class="operTotal">

						<view class="FiledBox" style="width: fit-content;">
							<text class="FiledBox_grifola" style="font-size: 14px;color: #333;" @click="openSelections">
								<text>合计</text>
								<text style="margin: 0 4px;">{{selections.length}}</text>
								<text>件</text>
							</text>
						</view>

					</view>
					<view class="operBtn">
						<u-row gutter="10">
							<u-col span="12">
								<u-button class="CommonBtnSize" type="primary" text="确定"
									@click="submitImport"></u-button>
							</u-col>
						</u-row>


					</view>


				</view>

			</template>


		</z-paging>
		<!-- <u-calendar :show="calendarShow" mode="range" :closeOnClickOverlay="true" :minDate="calMinDate"
			:maxDate="calMaxDate" :allowSameDay="true" monthNum="15" @confirm="confirmCalendar"
			@close="closeCalendar"></u-calendar> -->
		<uni-popup ref="popup" @close="closeSelect" type="right">
			<view class="f-dc" style="width: 80vw;height: 100%;background-color: #fff;"
				:style="$utils.disposeSafeBottomFun()">
				<u-navbar :fixed="false" title="筛选" :autoBack="false" leftIcon=" " :safeAreaInsetTop="true"
					leftIconColor="#fff" style="width: 100%;">
					<view class="u-nav-slot" slot="right">
						<uni-icons color="#fff" type="close" size="30" @click="closeSelect"></uni-icons>
					</view>
				</u-navbar>
				<view class="FilterBox">
					<view class="FiledBox x-bc" style="padding: 10px 15px;" v-for="row in formDesign"
						v-if="row.baseProperty.controlType == 'textbox'">
						<text class="FiledBox_label_x15 FiledBox_grifola"
							style="color: #333;width:100px;">{{row.baseProperty.labelName}}</text>

						<view class="x-ec" style="width:100%">
							<u--input type="text" placeholder="请输入" v-model="formData[row.baseProperty.controlName]"
								border="none" style="width:100%"
								v-if="row.baseProperty.controlType == 'textbox'"></u--input>
						</view>

					</view>
					<view class="FiledBox x-bc" style="padding: 10px 15px;" v-for="row in formDesign"
						v-if="row.baseProperty.controlType=='select' && row.controlProperty.select.type == 3">
						<text class="FiledBox_label_x15 FiledBox_grifola" style="color: #333;">{{row.colDesc}}</text>

						<view class="x-ec">
							<text class="FiledBox_value FiledBox_value_x14 FiledBox_grifola"
								style="color: #585858;">{{formData[row.colName+'_show']}}</text>
							<uni-icons type="right" size="18" color="#999"></uni-icons>
						</view>
					</view>
				</view>

				<view style="padding: 10px;background:#fff;">
					<u-row :gutter="10">
						<u-col span="6">
							<u-button text="重置"></u-button>
						</u-col>
						<u-col span="6">
							<u-button type="primary" text="确定" @click="searchReport"></u-button>
						</u-col>
					</u-row>
				</view>

			</view>
		</uni-popup>
		<uni-popup ref="popup2" type="bottom" @close="closeSelections">
			<u-list style="height:50vh;background-color: #fff;">
				<u-list-item v-for="(item, index) in selections" :key="index">
					<u-cell :title="`${index + 1} ${item[columns[0].colName]} `">
						<u-icon slot="right-icon" name="trash" @click="deleteSelection(item)"></u-icon>
					</u-cell>
				</u-list-item>
			</u-list>
		</uni-popup>
	</view>


</template>

<script>
	import layerFun from '@/common/comFun/layerFun.js';
	var layer = layerFun;
	// var vm;
	export default {
		data() {
			return {
				importDataListen: "importData", // 导入功能监听器
				backTopType: false, // 定义是否开启回到顶部
				DropDowmMenu_test: {},
				stickShow: false,
				DropDowmMenu_Date: { // 时间下拉
					// DateTitle: '全部',
					// SDate: '',
					// EDate: '',
				},

				titleName: '',
				moduleName: '',
				columns: [],
				workList: [],
				crudList: [],
				params: [],
				titleCol: {},
				keyName: '',
				queryColumns: [],
				tagCols: [],
				paging: {
					pageSize: 30,
					pageIndex: 1,
					totalCount: 0
				},
				searchPlaceHolder: '',
				menuShow: false,
				calendarShow: false,
				queryConditions: {},
				curQueryDate: {},
				menuExtraOperShow: false,
				calMinDate: '1950-1-1',
				calMaxDate: '2050-1-1',
				formMenus: [{
					id: 0,
					name: '回到顶部',
					value: '',
					// icon: 'arrow-up-fill'
				}],
				selectStyle: {
					top: '120px',
					width: '350px'
				},
				keyword: '',
				searchDLLTitles: [],
				tableData: [],
				formData: {},
				selections: [],
				showSelections: true,
				formDesign: [],
				importJs: '',
				showFormData: {}, // 存储需要隐藏的标题头展示的数据
			}
		},
		onUnload() {
			uni.$off("importSelectPicker");
			// uni.$off(this.importDataListen);
			uni.$off("selectPicker");
		},
		onLoad(option) {
			// 定义导入的监听器
			let importDataListen = "importData"
			if (!this.$utils.isEmpty(option)) {
				importDataListen = option.listen;
			};
			this.importDataListen = importDataListen;
		},
		onReady() {
			let vm = this;
			//弹窗下拉数据选择
			uni.$on('importSelectPicker', function(data) {
				//单选下直接赋值
				var curCol = vm.columns.filter(function(item) {
					return item.colName == data.colName
				});
				vm.queryConditions[data.colName] = data.data[curCol[0].selDetail.hiddenValue];
				vm.queryConditions[data.colName + '_show'] = data.data[curCol[0].selDetail.displayValue];
				vm.$forceUpdate();
			})
		},
		onShow() {

		},
		created() {
			let that = this;
			let vm = this;
			// vm = that;
			//获取当前页面对象
			let importPickerSetting = this.$store.state.ImportPickerSetting;
			that.titleName = importPickerSetting.name;
			// setZPXConfig({
			//     'default-page-size': 30,
			//     'empty-text': '查无数据',
			//     //...
			// });
			//console.log(that.getMinDate('y',-1));
			that.calMinDate = that.Request.dateFormat(that.getMinDate('y', -1), 'yyyy-MM-dd')
			that.calMaxDate = that.Request.dateFormat(that.getMinDate('m', 3), 'yyyy-MM-dd');

			that.initConfig(importPickerSetting);
		},
		watch: {
			backTopType: {
				handler(nval, oval) {
					this.formMenus[0]['name'] = (nval ? '关闭' : '开启') + '回到顶部'
				},
				immediate: true,
			},
		},
		methods: {
			VForFilterDataBack(data) { // v-for的列表数据过滤
				let that = this;

				return data.filter((col) => {
					return !col.isHidden && col.colName != that.showFormData.colName
				})
			},
			dropDowmOpen(data) { // 下拉菜单打开时触发

				let theKey = Object.keys(this.DropDowmMenu_Date)[data.index];
				if (this.$utils.isEmpty(this.DropDowmMenu_Date[theKey])) {
					this.DropDowmMenu_Date[theKey] = this.Request.dateFormat(new Date(), 'Y-MM-dd');
				}

				this.stickShow = false;
			},
			titleBackFun(item, comfig) {
				let findData = comfig.find(item => !item.isHidden);

				if (this.$utils.isEmpty(findData)) {
					return item[comfig[0].colName]
				}

				return item[findData.colName] || '';
			},
			DateSubmit(backDate, row) { // 选中时间
				let data = backDate.trim('')

				// 这里是非组合式日期选择控件
				this.queryConditions[row.baseProperty.controlName] = data;
				this.queryConditions[row.baseProperty.controlName + '_show'] = data;
				this.DropDowmMenu_Date[row.baseProperty.controlName] = data;

				// if (this.$utils.isEmpty(data.SDate)) {
				// 	if (row.baseProperty.controlName in this.queryConditions) {
				// 		delete this.queryConditions[row.baseProperty.controlName]
				// 	}

				// } else {
				// 	this.queryConditions[row.baseProperty.controlName] = data.SDate + '->' + data.EDate;
				// }
				// this.queryConditions[row.baseProperty.controlName + '_show'] = data.DateTitle;
				// this.DropDowmMenu_Date[row.baseProperty.controlName] = this.$utils.deepClone(data);

				this.$refs.mDropdown.close();
				this.$refs.paging.reload();
			},
			MenuTitleBack(row) {
				let FilterData = this.getQuerySelectColumns(row).filter(item => {
					return item.value == this.queryConditions[row.colName];
				});
				if (FilterData.length) {
					// console.log(FilterData)
					return FilterData[0]['text'];
				} else {
					// console.log(row)
					return row.colDesc || '请选择'
				}
			},
			changeValue() { // 切换普通下拉cell选项
				this.$refs.paging.reload()
			},
			post(sql, param, callBack) {
				let vm = this;
				param["sql"] = sql;
				if (vm.Request.getUserInfo()) {
					if (!param.hasOwnProperty("P_UserID")) {
						param.P_UserID = vm.Request.getUserInfo().UserID;
					}
					if (!param.hasOwnProperty("P_UserName")) {
						param.P_UserName = vm.Request.getUserInfo().UserName;
					}
					if (!param.hasOwnProperty("P_UserCode")) {
						param.P_UserCode = vm.Request.getUserInfo().UserCode;
					}
				}
				vm.Request.requestByUrl("/SQLData/QuerySql", param, function(data) {
					callBack(data);
				}, function(err) {
					console.log(err)
				});
				//vm.handleSizeChange(vm.paging.pageIndex);
			},
			initConfig(importPickerSetting) {
				let vm = this;
				var that = this;
				that.sql = importPickerSetting.sql;
				that.columns = importPickerSetting.columns;
				that.importJs = importPickerSetting.importJs;

				let findData = that.columns.find(item => !item.isHidden);

				// console.log(findData)
				if (!this.$utils.isEmpty(findData)) {
					this.showFormData = findData;
				}

				var rowDesignFormData = [];

				let {
					formDesign,
					originFormData
				} = importPickerSetting

				formDesign.forEach((item, index) => {
					if (item.baseProperty.defaultValue && item.baseProperty.defaultValue.indexOf('@') >= 0) {

						if (originFormData && originFormData[item.baseProperty.defaultValue.substring(1)]) {
							vm.$set(vm.formData, item.baseProperty.controlName, originFormData[item.baseProperty
								.defaultValue.substring(1)]);
						} else {
							vm.$set(vm.formData, item.baseProperty.controlName, "");
						}
					} else {
						let DefauleData = item.baseProperty.defaultValue;

						// 如果没有默认值，切数据是日期类型
						if (that.$utils.isEmpty(item.baseProperty.defaultValue) &&
							item.baseProperty.controlType == 'datepicker') {
							DefauleData = 'getdate()'
						}
						let backDate = vm.getSYDefaultValue(DefauleData);
						vm.$set(vm.formData, item.baseProperty.controlName, backDate);

						if (item.baseProperty.controlType == 'datepicker') {

							let dates = that.Request.dateFormat(new Date(backDate), 'Y-MM-dd');

							let controlName = item.baseProperty.controlName

							that.DropDowmMenu_Date[controlName] = dates;

							that.queryConditions[controlName] = dates;
							that.queryConditions[controlName + '_show'] = dates;
						}
					}
				})
				vm.formDesign = formDesign;




				/* for (var i = 0; i < importPickerSetting.formDesign.length; i++) {
					//增加查询默认值
					if (importPickerSetting.formDesign[i].baseProperty.defaultValue && importPickerSetting.formDesign[i]
						.baseProperty.defaultValue.indexOf('@') >= 0) {
						if (importPickerSetting.originFormData && importPickerSetting.originFormData[importPickerSetting
								.formDesign[i].baseProperty.defaultValue.substring(1)]) {
							vm.$set(vm.formData, importPickerSetting.formDesign[i].baseProperty.controlName,
								importPickerSetting.originFormData[importPickerSetting.formDesign[i].baseProperty
									.defaultValue.substring(1)]);
						} else {
							vm.$set(vm.formData, importPickerSetting.formDesign[i].baseProperty.controlName, "");
						}
					} else {

						let DefauleData = importPickerSetting.formDesign[i].baseProperty.defaultValue;

						// 如果没有默认值，切数据是日期类型
						if (that.$utils.isEmpty(importPickerSetting.formDesign[i].baseProperty.defaultValue) &&
							importPickerSetting.formDesign[i].baseProperty.controlType == 'datepicker') {
							DefauleData = 'getdate()'
						}
						let backDate = vm.getSYDefaultValue(DefauleData);
						vm.$set(vm.formData, importPickerSetting.formDesign[i].baseProperty.controlName, backDate);



						if (importPickerSetting.formDesign[i].baseProperty.controlType == 'datepicker') {

							let dates = that.Request.dateFormat(new Date(backDate), 'Y-MM-dd');

							let controlName = importPickerSetting.formDesign[i].baseProperty.controlName

							that.DropDowmMenu_Date[controlName] = dates;

							that.queryConditions[controlName] = dates;
							that.queryConditions[controlName + '_show'] = dates;
						}
					}


					//var rowId = importPickerSetting.formDesign[i].baseProperty.rowId;
					// if (options.formDesign[i].baseProperty.controlType == "select") {
					// 	//下拉框数据加载
					// 	if (options.formDesign[i].controlProperty.select.type < 3) {
					// 		var sql = options.formDesign[i].controlProperty.select.dataSource;
					// 		$.ajax({
					// 			url: "/SQLData/GetDataBySql",
					// 			async: false,
					// 			data: {
					// 				programId: localStorage.getItem("programId"),
					// 				sql: sql
					// 			},
					// 			type: "post",
					// 			dataType: 'json',
					// 			success: function (data) {
					// 				if (data.status == 200) {
					// 					options.formDesign[i].controlProperty.select.sqlDataSource = data.data.ds;
					// 					options.formDesign[i].controlProperty.select.originDataSource = data.data.ds;
					// 				}
					// 			}
					// 		});
					// 	}
					// 	else if (options.formDesign[i].controlProperty.select.type == 3) {
					// 		var valueList = [];
					// 		if (vm.formData[options.formDesign[i].baseProperty.controlName] != undefined && vm.formData[options.formDesign[i].baseProperty.controlName] != "") {
					// 			valueList.push("'" + vm.formData[options.formDesign[i].baseProperty.controlName] + "'");
					// 		}
					// 		var sql = "select * from (" + options.formDesign[i].controlProperty.select.dataSource + ")t";
					// 		if (valueList.length > 0) {
					// 			sql += " where " + options.formDesign[i].controlProperty.select.hiddenValue + " in (" + valueList.join(',') + ") ";
					// 			$.ajax({
					// 				url: "/SQLData/GetDataBySql",
					// 				async: false,
					// 				data: {
					// 					programId: localStorage.getItem("programId"),
					// 					sql: sql
					// 				},
					// 				type: "post",
					// 				dataType: 'json',
					// 				success: function (data) {
					// 					if (data.status == 200) {
					// 						//options.formDesign[i].controlProperty.select["sqlDataSource"] = data.data.ds;
					// 						//options.formDesign[i].controlProperty.select["originDataSource"] = data.data.ds;
					// 						vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", data.data.ds);
					// 						vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", data.data.ds);
					// 						//绑定固定值
					// 						vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
					// 						//options.formDesign[i].controlProperty.select["actualName"] = "";
					// 						var actualList = JSLINQ(data.data.ds).where(function (item) { return item[options.formDesign[i].controlProperty.select.hiddenValue] == vm.formData[options.formDesign[i].baseProperty.controlName] }).ToArray();
					// 						if (actualList.length > 0) {
					// 							vm.$set(options.formDesign[i].controlProperty.select, "actualName", actualList[0][options.formDesign[i].controlProperty.select.displayValue]);
					// 							//options.formDesign[i].controlProperty.select["actualName"] = actualList[0][options.formDesign[i].controlProperty.select.displayValue];
					// 						}
					// 					}
					// 				}
					// 			});
					// 		}
					// 		else {
					// 			vm.$set(options.formDesign[i].controlProperty.select, "sqlDataSource", []);
					// 			//options.formDesign[i].controlProperty.select["sqlDataSource"] = [];
					// 			vm.$set(options.formDesign[i].controlProperty.select, "originDataSource", []);
					// 			//options.formDesign[i].controlProperty.select["originDataSource"] = [];
					// 			vm.$set(options.formDesign[i].controlProperty.select, "actualName", "");
					// 			//options.formDesign[i].controlProperty.select["actualName"] = [];
					// 		}
					// 	}
					// }

				}
				vm.formDesign = importPickerSetting.formDesign; */


				// let customValue = {
				// 	DateTitle: '',
				// 	SDate: '',
				// 	EDate: '',
				// }
				// let backDate = importPickerSetting.formDesign.filter(row => row.baseProperty.controlType == 'datepicker')


				// let newObject = backDate.reduce((acc, curr) => {
				// 	// 将当前对象的 colName 作为新对象的属性名  
				// 	// 将自定义的对象作为属性值  
				// 	acc[curr.baseProperty.controlName] = '';
				// 	return acc;
				// }, {});
				// vm.DropDowmMenu_Date = vm.$utils.deepClone(newObject)


				that.searchReport(importPickerSetting);
			},
			//分页事件
			searchReport(importPickerSetting) {
				let vm = this;
				vm.$utils.showLoading();
				//验证必填项
				//var valitedResult = vm.valitedRequired();
				// if (valitedResult.status == 500) {
				// 	layer.msg(valitedResult.msg);
				// 	vm.closeLoading();
				// 	return;
				// }
				// else {
				var searchParam = [];

				Object.keys(vm.formData).forEach(key => {

					if (key in vm.DropDowmMenu_Date) {
						vm.formData[key] = vm.DropDowmMenu_Date[key]
					}
				})


				for (var key in vm.formData) {
					searchParam.push({
						Key: key,
						Value: vm.formData[key]
					})
				};

				vm.Request.requestByUrl('/SQLData/GetDataBySql_Uniapp', {
					sql: vm.sql,
					sqlParamStr: JSON.stringify(searchParam)
				}, function(data) {

					vm.$utils.hideLoading(1000);
					vm.$refs.paging.setLocalPaging(data.ds);

					// 强制关闭筛选弹层
					vm.closeSelect();
				}, function(err) {
					console.log(err);
				});
				// }
			},
			isShowColumns(colObj) {
				let vm = this;
				var that = this;
				var showColumns = uni.getStorageSync(that.moduleName + '_ShowColumns');
				var isShow = true;
				if (showColumns) {
					if (showColumns.filter(function(item) {
							return item == colObj.colName
						}).length == 0) {
						isShow = false;
					}
				}
				return isShow;
			},
			//获取查询下拉数据源	
			getQuerySelectColumns(row) {
				let vm = this;
				let MapData = row.selDetail.sqlDataSource.map(function(item) {
					return {
						text: item[row.selDetail.displayValue],
						value: item[row.selDetail.hiddenValue]
					}
				});
				return MapData
			},
			getMinDate(strInterval1, Number1) {
				let vm = this;
				var date;
				date = new Date();
				Date.prototype.DateAdd = function(strInterval, Number) {
					var dtTmp = this;
					switch (strInterval) {
						case 's':
							return new Date(Date.parse(dtTmp) + (1000 * Number));
						case 'n':
							return new Date(Date.parse(dtTmp) + (60000 * Number));
						case 'h':
							return new Date(Date.parse(dtTmp) + (3600000 * Number));
						case 'd':
							return new Date(Date.parse(dtTmp) + (86400000 * Number));
						case 'w':
							return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
						case 'q':
							return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp.getDate(),
								dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
						case 'm':
							return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(), dtTmp
								.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
						case 'y':
							return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(), dtTmp
								.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
					}
				}
				return date.DateAdd(strInterval1, Number1);
			},
			// confirmCalendar(date) {
			// 	vm.calendarShow = false; 
			// 	vm.curQueryDate.selfDate = date[0].split('-')[1] + '/' + date[0].split('-')[2] + '~' + date[date.length -
			// 		1].split('-')[1] + '/' + date[date.length - 1].split('-')[2];
			// 	vm.queryConditions[vm.curQueryDate.colName] = date[0] + '->' + date[date.length - 1];
			// 	vm.handleSizeChange(1, 30);
			// },
			// closeCalendar() {
			// 	vm.calendarShow = false;
			// },
			//初始化下拉数据源
			initSelectValue() {
				let vm = this;
				var requestSelectSql = []
				for (var i = 0; i < vm.columns.length; i++) {
					//下拉控件
					if (vm.columns[i].colType == 2) {
						//普通下拉
						if (vm.columns[i].selDetail.type == 1) {
							var sql = vm.columns[i].selDetail.dataSource;
							vm.columns[i].selDetail.sqlDataSource = [];
							vm.columns[i].selDetail.originDataSource = [];

							var requestSql = vm.Request.PromiseRequestByUrl('/SQLData/GetDataBySql', {
								sql: sql
							});
							requestSelectSql.push({
								index: i,
								request: requestSql
							});
						}
					}
				}
				requestSelectSql.forEach(function(item) {
					item.request.promise.then(function(data) {
						vm.$set(vm.columns[item.index].selDetail, "sqlDataSource", data.data.ds);
						vm.$set(vm.columns[item.index].selDetail, "originDataSource", data.data.ds);
					})
				})
			},
			//显示标签颜色状态
			showTagStatus(tagName) {
				if (tagName.indexOf('通过') >= 0 || tagName.indexOf('成功') >= 0) {
					return "success";
				} else {
					return "warning";
				}
			},
			showPopup() {
				this.menuShow = true;
			},
			queryList() {
				let that = this;

				that.$utils.showLoading();

				let data = []


				that.$refs.paging.complete(data);
			},
			TapPopup(data) { // 选中气泡项

				switch (data.id) {
					case 0: // 回到顶部
						this.backTopType = !this.backTopType;

						break;
					default:
						break;
				}

			},
			openMenuExtraOper() {
				let vm = this;
				vm.menuExtraOperShow = true;
			},
			//新增
			choiceItem(item) {
				let vm = this;
				if (vm.selections.filter(function(obj) {
						return obj == item
					}).length == 0) {
					vm.selections.push(item);
				}
			},
			isSelectedItem(item) {
				let vm = this;
				if (this.$utils.isEmpty(vm.selections)) {
					// 未选中过数据
					return false
				} else {
					// 有选中数据，判断是否有相同的数据

					const filterNum = vm.selections.some(row => {
						return JSON.stringify(row) == JSON.stringify(item);
					});

					return filterNum
				}
			},
			openSelections() {
				this.$refs.popup2.open('bottom')
			},
			closeSelections() {
				this.$refs.popup2.close()
			},
			choiceParams() {
				this.$refs.popup.open('right')
			},
			closeSelect() {
				this.$refs.popup.close()
			},
			deleteSelection(item) {
				let vm = this;
				vm.selections = vm.selections.filter(function(obj) {
					return obj != item
				})
			},
			openBaseScreen(row) {
				let vm = this;
				var obj = {
					chooseType: row.selDetail.chooseType,
					allowClear: true,
					showSearch: true,
					searchKey: row.selDetail.displayValue,
					serverSearch: true,
					displayValue: row.selDetail.displayValue,
					hiddenValue: row.selDetail.hiddenValue,
					parentValue: row.selDetail.parentValue,
					isPaging: true,
					sql: row.selDetail.dataSource,
					name: row.colDesc,
					colName: row.colName,
					param: {},
					treeObj: {
						treeDataSource: row.selDetail.treeDataSource,
						treeDisplayValue: row.selDetail.treeDisplayValue,
						treeHiddenValue: row.selDetail.treeHiddenValue,
						treeParentValues: row.selDetail.treeParentValues,
					}
				}
				obj.param[row.selDetail.displayValue] = "";

				vm.$store.commit('ChangeAndSetStateData', {
					Name1: 'SelectPickerSetting',
					data: obj
				});

				uni.navigateTo({
					url: '/commonPage/Tool/selectPicker' + '?pickerListen=importSelectPicker'
				})
			},
			//导入数据
			submitImport() {
				let vm = this;
				if (vm.importJs) {
					eval(vm.importJs);
				} else {
					uni.$emit(vm.importDataListen, {
						selections: vm.selections,
						columns: vm.columns
					});
					uni.navigateBack();
				}
			},
			//系统默认常量时间
			getSYDefaultValue(funcName) {
				let vm = this;
				if (funcName.indexOf("getdate()") >= 0) {
					var date;
					if (funcName == "getdate()") {
						date = new Date();
					} else {
						date = new Date();
						Date.prototype.DateAdd = function(strInterval, Number) {
							var dtTmp = this;
							switch (strInterval) {
								case 's':
									return new Date(Date.parse(dtTmp) + (1000 * Number));
								case 'n':
									return new Date(Date.parse(dtTmp) + (60000 * Number));
								case 'h':
									return new Date(Date.parse(dtTmp) + (3600000 * Number));
								case 'd':
									return new Date(Date.parse(dtTmp) + (86400000 * Number));
								case 'w':
									return new Date(Date.parse(dtTmp) + ((86400000 * 7) * Number));
								case 'q':
									return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number * 3, dtTmp
										.getDate(), dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
								case 'm':
									return new Date(dtTmp.getFullYear(), (dtTmp.getMonth()) + Number, dtTmp.getDate(),
										dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
								case 'y':
									return new Date((dtTmp.getFullYear() + Number), dtTmp.getMonth(), dtTmp.getDate(),
										dtTmp.getHours(), dtTmp.getMinutes(), dtTmp.getSeconds());
							}
						}
						var addFun = funcName.split('.')[1];
						eval("date=date." + addFun);
					}
					var seperator1 = "-";
					var seperator2 = ":";
					var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
					var strDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
					var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate +
						" " + date.getHours() + seperator2 + date.getMinutes() +
						seperator2 + date.getSeconds();
					return currentdate;
				} else if (funcName.indexOf("$.cookie") >= 0) {
					return eval(funcName);
				} else if (funcName.indexOf('func:') >= 0) {
					return eval(funcName.split(':')[1]);
				} else if (funcName.indexOf("@") >= 0) {
					if (funcName == '@P_UserID') {
						return {
							P_UserID: uni.getStorageSync("UserInfo").UserID,
							P_UserName: uni.getStorageSync("UserInfo").UserName
						}
					} else if (funcName == '@EmplID') {
						return {
							P_UserID: uni.getStorageSync("UserInfo").EmplID,
							P_UserName: uni.getStorageSync("UserInfo").UserName
						}
					}
				} else if (funcName.indexOf('localStorage.getItem') >= 0) {
					return eval(funcName);
				} else {
					return funcName;
				}
			}
		}
	}
</script>


<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		height: 100vh;
		// height: calc(100vh - 60px);
		// background-color: #f9f9f9;
		background-color: #f2f2f2;

		uni-button {
			margin-left: initial !important;
			margin-right: initial !important;
		}

		.MenuBoxMax {
			height: 42px;
			position: relative;
			width: 100%;
			border-bottom: 4px solid #f2f2f2;

			.MenuBox {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				background-color: #fff;

				.selectSearchDom {
					padding-right: 10rpx;
				}
			}
		}

		.MainPopup {
			flex: initial !important;

			.PopupContent {
				display: flex;
				flex-direction: column;
				min-height: 240px;
				width: 90vw;
			}

			.u-transition {
				z-index: 99999 !important;
			}


			.PopupMainBox {
				padding: 12px 10px 6px;
				flex: 1;
				// overflow: auto;

				.CellBox {
					margin-bottom: 20px;

					.LeftBox {
						font-size: 14px;
						color: #999;
						margin-right: 10px;
					}
				}

				.uni-input-placeholder {
					color: #6a6a6a !important;
					font-size: 12px !important;
				}
			}

			.PopupBottomBox {
				display: flex;
				align-items: center;
				justify-content: flex-end;
				padding: 10px 10px;

				.CancelBtn {
					background-color: #fff;
					color: #51d0d0;
					border: 1px solid #51d0d0;
					min-width: 80px;
				}

				.ComfirmBtn {
					background-color: #51d0d0;
					color: #fff;
					min-width: 80px;
					margin-left: 10px !important;
				}
			}
		}

		.MainBox {
			// flex: 1;
			// overflow: auto;
			padding: 10rpx;

			// 表单1
			.u-form {
				// padding: 0px 10px;

				.u-form-item {
					background-color: #fff;
					padding: 0 16px;
				}


				.TopOption {

					.u-form-item__body {
						flex-direction: column !important;
					}
				}

				// 起止时间
				.ChoiceTimesBox {
					width: 100%;
					display: flex;
					align-items: center;
					// background-color: #fff;
					// padding: 18px 10px;
					// margin-top: 10px;

					.TimeBox {
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-evenly;

						.timer {
							width: 100%;
							flex: 2;
							display: flex;
							flex-direction: column;
							// align-items: center;
							font-size: 16px;
							color: #333;

							text:first-child {
								margin-bottom: 10px;
								font-weight: 600;
							}

							text:last-child {
								height: 20px;
							}
						}

						.Icon {
							flex: 1;
						}
					}
				}


				// 上传-删除图标
				.u-upload__deletable {
					width: 20px;
					height: 20px;

					.u-upload__deletable__icon {
						right: -1px !important;

						.u-icon__icon {
							font-size: 20px !important;
							line-height: 16px !important;
						}
					}
				}
			}
		}

		.BottomBox {
			width: 100%;
			// height: 70px;
			// line-height: 70px;
			padding: 6px 15px;
			border-top: 1px solid #efefef;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			background-color: #fff;
			// padding-bottom: constant(safe-area-inset-bottom) !important;
			// padding-bottom: env(safe-area-inset-bottom) !important;
		}

		.moremenu {
			margin-right: 10rpx;
		}

		.search {
			// background-color: #fff;
			// padding: 10rpx;


			background-color: #fff;
			background-color: #51d0d0;
			padding: 6px 10px;
		}

		.searchDom {
			width: calc(100% - 40rpx);
			float: left;
		}

		.scanQrCode {
			width: 20rpx;
			margin-right: 15rpx;
			padding: 5rpx;
			float: right;
		}

		.list {
			background-color: #999;
		}

		.bottomTool {
			background: #fff;
			padding: 15rpx;
			border-top: 2px solid #f2f2f2;
			// box-shadow: inset 0px 5px 7px -7px #878787;
			// box-shadow: 1px 0 12px -9px #333;
			// height: 100rpx;
		}

		.operTotal {
			// width: calc(100% - 300rpx);
			// float: left;
		}

		.operBtn {
			// width: 280rpx;
			// float: right;
			// padding: 10rpx;
		}

		.FilterBox {
			flex: 1;

			.FiledBox {
				position: relative;

				&::after {
					position: absolute;
					box-sizing: border-box;
					content: ' ';
					pointer-events: none;
					right: 16px;
					bottom: 0;
					left: 16px;
					border-bottom: 1px solid #ebedf0;
					-webkit-transform: scaleY(0.5);
					transform: scaleY(0.5);
				}

				&:last-child::after {
					border-bottom: none;
				}
			}
		}
	}
</style>